<?php

class Blogs_model extends CI_Model {

    private $_table = 'articles';

    public function get_blogs($params) {
        $where = array(
            'type' => TYPE_BLOG
        );
        $query = $this->db->get_where($this->_table, $where, PER_PAGE_BLOG, $params['offset']);
        return $query->result_array();
    }

    public function get_blog($params) {
        $where = array(
            'type'  => TYPE_BLOG,
            'id'    => $params['id']
        );
        $query = $this->db->get_where($this->_table, $where, PER_PAGE, $params['offset']);
        return $query->row();
    }

    public function get_num_rows($params = array()) {
        $where = array(
            'type'  => TYPE_BLOG
        );
        $query = $this->db->get_where($this->_table, $where);
        return $query->num_rows();
    }

}
